home *** CD-ROM | disk | FTP | other *** search
- /*
- * CSignedObject.h
- * Copyright © 1993 Apple Computer Inc.
- * All Rights Reserved
- *
- * This is a Think C class library definition that permits
- * any Think C object to have an attached digital signature.
- * Methods allow you to attach, save, restore, and verify
- * signatures.
- *
- * Note that this class signs objects, which might be any
- * component of an application, such as a cell in a spreadsheet
- * or even the position of an object in a drawing program.
- * In the real world, you would probably use CSignedDataFile
- * where the signature verifies the content of an entire document.
- *
- * Note: errors are returned through the Think Class
- * Library "Failure" routines.
- *
- * Normal usage:
- * Adding a signature to an object:
- * myObject->itsSignature = new (CSignedObject);
- * myObject->itsSignature->ISignedObject();
- * Creating a signature:
- * myObject->itsSignature->SignPrepare();
- * myObject->itsSignature->ProcessData();
- * myObject->itsSignature->Sign();
- * Normal usage (verifying an object):
- * myObject->itsSignature->ReadSignature(myFile);
- * myObject->itsSignature->VerifyPrepare();
- * myObject->itsSignature->ProcessData();
- * myObject->itsSignature->Verify();
- */
-
- #define _H_CSignedObject
- #include "CSignature.h"
-
- struct CSignedObject : CSignature {
- private:
- /*
- * itsSignature is the actual signature.
- */
- SIGSignaturePtr itsSignature;
- /*
- * itsSignatureSize is the size of itsSignature.
- */
- Size itsSignatureSize;
-
- public:
- void ISignedObject(void);
- void Dispose(void);
- /*
- * Override SignPrepare so we retain the
- * signature size. See CSignature.h for
- * the parameter definitions.
- */
- Size SignPrepare(
- const FSSpec *signerFile,
- ConstStr255Param prompt
- );
- /*
- * Sign computes the full signature for the data
- * that was processed by calling ProcessData.
- * statusProc is an optional callback procedure
- * that you can provide to notify the user of
- * the signature creation progress. Specify
- * NULL if you do not wish to provide a callback
- * procedure.
- */
- void Sign(
- SIGStatusProcPtr statusProc
- );
- /*
- * VerifyPrepare initializes the verification
- * process.
- */
- void VerifyPrepare(
- SIGStatusProcPtr statusProc
- );
- /*
- * Verify tests the validity of the specified
- * signature.
- */
- void Verify(void);
- /*
- * Process data passes some data through
- * the signer/verifier. Data does *not*
- * need to be in a locked handle.
- */
- void ProcessData(
- const void *data,
- Size dataSize
- );
- /*
- * Return the signature size.
- */
- Size GetSignatureSize(void);
- /*
- * Create a signature buffer using the current
- * signature size.
- */
- void NewSignature(void);
- /*
- * Dispose of the current signature buffer without
- * disposing of the context.
- */
- void DisposeSignature(void);
- /*
- * True if there is an associated signature.
- */
- Boolean HasSignature(void);
- /*
- * Fail with an appropriate error (kSIGNoSignature)
- * if there is no signature.
- */
- void CheckForSignature(void);
- /*
- * Copy the current signature to the user's buffer.
- * Fail with paramErr if there is no signature or
- * the caller's bufferSize is smaller than the
- * current signature size. Return the actual
- * signature size.
- */
- Size CopySignatureToUserBuffer(
- void *buffer,
- Size bufferSize
- );
- /*
- * Create a signature buffer using the information
- * provided by the caller. This is needed if an
- * object's signature is stored/restored by the
- * application.
- */
- void MakeSignatureFromUserBuffer(
- void *buffer,
- Size bufferSize
- );
- /*
- * Write a signature to an existing file. You would
- * call this as part of your "save this object"
- * process. aFile is the Think C Class file object.
- *
- * The function works correctly even if there is no
- * current signature (it writes a zero-length record
- * that is understood by ReadSignature).
- */
- void WriteSignature(
- CDataFile *aFile
- );
- /*
- * Read a signature from an open file. You would
- * call this as part of your "restore this object"
- * process. Fails with paramErr if the next thing
- * read is not a signature. Succeeds without error
- * if there was no signature written.
- */
- void ReadSignature(
- CDataFile *aFile
- );
- };
-